package ACM;

import java.util.Scanner;

/**
 * @author way
 * @create 2025-03-28 19:37
 */
public class ELM_3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }

        long total = 0;
        // 遍历所有可能的子集（2^n种可能性）
        for (int mask = 0; mask < (1 << n); mask++) {
            // 检查子集中元素数量是否为k
            if (Integer.bitCount(mask) != k) continue;

            // 计算当前子集的异或和
            int xorSum = 0;
            for (int i = 0; i < n; i++) {
                if ((mask & (1 << i)) != 0) {
                    xorSum ^= arr[i];
                }
            }
            total += xorSum;
        }
        System.out.println(total);
    }
}
